package com.ymatou.iapi.dguser.service;

import com.google.common.reflect.TypeToken;
import com.ymatou.iapi.dguser.parameter.UserDto;
import com.ymt.base.YmatouBaseCall;
import com.ymt.core.tool.FormatUtil;
import com.ymttest.utils.EnvSetup;

import java.util.List;

/**
*获取用户列表Call
*FreeMaker Template自动生成代码
*/
public class GetUserListCall extends YmatouBaseCall{
	private static String opurl ="userquery/getuserlist";
	
	public GetUserListCall() {
		super(EnvSetup.getSystemUrl("dguser_iapi"),opurl,"POST","JSON");
	}
	@Override
	public void addDefHeader() {
		client.addHeader("Accept","text/xml,text/javascript,text/html,application/json");
		client.addHeader("Content-Type", "application/json; charset=UTF-8");
	}

	public List<UserDto> getUserDtos(){
		String sResults=getJsonObject().get("userDtos").getAsJsonArray().toString();
		List<UserDto> userDtos=(List<UserDto>) FormatUtil.GSONToObject(sResults, new TypeToken<List<UserDto>>(){}.getType());
		return userDtos;
	}
}